#include "StdAfx.h"
#include "MyMutex.h"

CMyMutex::CMyMutex(void)
{
	 m_sync = CreateMutex (NULL, false, NULL);
}

CMyMutex::~CMyMutex(void)
{
	if (m_sync != NULL)
	{
		CloseHandle (m_sync);
		m_sync = NULL;
	}
}
 
void CMyMutex::Enter () const
{
	
	WaitForSingleObject(m_sync, INFINITE);
}

void CMyMutex::Leave () const
{
	ReleaseMutex (m_sync);
}

void CMyMutex::operator =(CMyMutex &s)
{
	m_sync=s.m_sync;
}
CMyMutex::CMyMutex (CMyMutex& s)
{
	m_sync=s.m_sync;
}